<?php
/*
**个人空间设置，基本信息设置
**set.php
**By QINIAO
*/

require_once('init.php');

if(empty($cookienum))
{
redirect('index.php', 1, '非法访问，即将返回到首页！');
}

if($action == "")
{
require_once('model/class.user.php');
$qiUser = new qiUser($DB);
$truename = isset($_POST['truename']) ? $_POST['truename'] : '';
if(!empty($truename))
{
$qiUser->changeName($truename,$uid);
redirect('set.php', 1, '姓名修改成功，返回上一页！');
}

$xingTemplate->display('set_base');
}

if($action == "face")
{
require_once('inc/uploadpic.php');
if(isset($_FILES['picture'])){
$f=$_FILES['picture'];
if(empty($f['name']))
{
redirect('set.php?action=face', 1, '头像不能为空！');
}
elseif ($f['name']) {
if ($_FILES['picture']['type']!="image/jpg" && $_FILES['picture']['type']!="image/pjpeg" && $_FILES['picture']['type']!="image/jpeg" && $_FILES['picture']['type']!="image/gif" && $_FILES['picture']['type']!="image/png" && $_FILES['picture']['type']!="image/x-png" && $_FILES['picture']['type']!="image/bmp") {
echo "<script>alert(\"提示：你上传的头像图片类型不正确，系统仅支持 jpg,gif,png 格式的图片,点击确认返回！\");window.location.href='set.php?action=face';</script>";
}
}
$dest_dir='face';
$dest=$dest_dir.'/'.$uid."_".$f['name'];
$dest2=$dest_dir.'/'.$uid.".jpg";
$r=move_uploaded_file($f['tmp_name'],$dest);
chmod($dest, 0755);
$resizeimage = new resizeimage("$dest", "98", "98", "1","$dest2");
@unlink("$dest");

redirect('set.php?action=face', 1, '修改头像成功！跳转中！');
}

$xingTemplate->display('set_face');
}

if($action == "pwd")
{
$oldpwd = isset($_POST['oldpwd']) ? $_POST['oldpwd'] : '';
$newpwd = isset($_POST['newpwd']) ? $_POST['newpwd'] : '';
$repwd = isset($_POST['repwd']) ? $_POST['repwd'] : '';

$oldpwd = md5($oldpwd);
$newpwd = md5($newpwd);
$repwd = md5($repwd);

if(isset($_POST['editsubmit']))
{
require_once('model/class.user.php');
$qiUser = new qiUser($DB);
$qiUser->changeUserPwd($oldpwd,$newpwd,$uid);
}
$xingTemplate->display('set_password');
}

?>
